import axios from "axios";

const headers = {
  "user-agent":
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.61",
    host: "studio-api.suno.ai"
}

async function getTopLists() {
  return [
    {
      title: "SUNO原创音乐:pd97972529",
      data: [
      
      ],
    },
    {
      title: "最新榜",
      data: [
        {
          id: "7c1b035c-98b4-46c8-93d0-8eb32f0f1eb5",
          title: "穿越千年-古装",
          coverImg:"https://cdn2.suno.ai/image_552da34d-e919-409a-8133-ae8724f25545.jpeg",
          description:"古装穿越,甜美轻声"
        },
        {
          id: "eff71da6-bd9b-4e97-81fc-51ce8d833d42",
          title: "粤语小王子-Beyond",
          coverImg:"https://cdn2.suno.ai/image_312f69ba-7faf-4757-aa42-89ff22bee4f1.jpeg",
          description:"流行粤语新人-黄家驹等等"
        },
        {
          id: "d16d49b6-f9b0-4643-af69-3c3cc05ee177",
          title: "追光男孩",
          coverImg:"https://cdn2.suno.ai/image_0ef47a78-4827-40e3-bdfb-6fccbc064b70.jpeg",
          description:"流浪的男孩,追着光芒,这种光可以消除一切罪恶"
          
        },
      ],
    },
    {
      title: "古风",
      data: [
        {
          id: "8e1cd1ed-2285-414a-8d72-1a7d929f83e5",
          coverImg:"https://cdn2.suno.ai/224b6fe8.jpeg",
          title: "中国古风",
          description:"古今往來 盡皆黃粱一夢"
          
        },
        {
          id: "36996fa8-b8b7-46a2-ace6-4691e9ffe948",
          coverImg:"https://cdn2.suno.ai/030dec8f.jpeg",
          title: "情長幽茫茫 ",
          description:"一念生 一念死 終念蒼茫"
          
        }
      ],
    },
    {
      title: "度假",
      data: [
        {
          id: "ad9b15c3-d597-4ea4-93a2-babe0231f34f",
          coverImg:"https://cdn2.suno.ai/image_c4708f73-02ed-4004-b232-2e82c7df7878.jpeg",
          title: "假日愉快",
          description:"让度假歌陪你走过一个假期"
          
        }
     
      ],
    },
    {
      title: "驾驶",
      data: [
        {
          id: "e03023ba-89f9-452a-be8d-408fdfb1bbc7",
          coverImg:"https://cdn2.suno.ai/image_47cc8c27-4e93-4a29-9f96-61137d20ddfa.jpeg",
          title: "驾驶",
          description:"开车回家路上听"
          
        }
     
      ],
    },
    {
      title: "睡前",
      data: [
        {
          id: "363816c1-5b28-4ba3-9f57-2653ca6e0f6d",
          coverImg:"https://cdn2.suno.ai/image_59eebb46-012d-4890-95f1-a9ee2b1d5db2.jpeg",
          title: "助眠聆听",
          description:"睡前听听 助眠歌曲"
          
        }
     
      ],
    },
    {
      title: "抒情",
      data: [
        {
          id: "8f1fbf83-81e0-4c36-a247-d0ac90be7691",
          coverImg:"https://cdn2.suno.ai/3c7a5214-d6ba-4312-bd56-db56657c4a71_d1f84ca3.jpeg",
          title: "豬羊Soft rock+R&B专辑",
          description:"软摇滚, 原声 R&B, 沧桑与自省, 老人, 赎罪者"
          
        },
        {
          id: "2b26fe4b-b0da-4c57-8def-3d5f9664167c",
          coverImg:"https://cdn2.suno.ai/image_65281066-11a9-46ca-8ace-582551f763e8.jpeg",
          title: "猪羊-中文歌曲、纯音乐",
          description:"台湾民歌，暖心"
          
        },
        {
          id: "0deb515a-df94-4e3f-aaad-142bb321f948",
          coverImg:"https://cdn2.suno.ai/c3b57d85-ae83-42fb-861d-840e125ea4e1_d988af36.jpeg",
          title: "豬羊抒情歌+流行歌",
          description:"古典大提琴，抒情歌曲"
          
        }
        
      
       
      ],
    },
    {
      title: "轻音乐｜放松",
      data: [
      
      
        {
          id: "9b358354-bf12-4d38-b57d-43c3d3cb055c",
          coverImg:"https://cdn2.suno.ai/image_c6946e12-c83c-4565-a5ac-5e3587f5d4fd.jpeg",
          title: "华文音乐",
          description:"一起创作歌曲，让自己的生活更快乐"
          
        }
      ],
    },
    {
      title: "原创流行|POP",
      data: [
        {
          id: "136544e1-f6f5-4397-ae3f-d719a2389b1f",
          coverImg:"https://cdn2.suno.ai/6cca452e.jpeg",
          title: "流行｜pop",
          description:"悲傷與絕望 迴盪在天地間 "
        },
        
      ],
    },
    {
      title: "二次元｜游戏BGM",
      data: [

        
        {
          id: "2a7546c2-bf33-42e9-b669-1529f79dcf74",
          coverImg:"https://cdn2.suno.ai/image_58993594-1c7c-4a1a-8fc7-31dcdc90c14b.jpeg",
          title: "初音ミク",
          description:"マスター｜音乐制作、游戏"
        },
        {
          id: "6a374b56-e27b-41eb-96bc-98b49aa56095",
          coverImg:"https://cdn2.suno.ai/d268ed18.jpeg",
          title: "VOCALOID",
          description:"Exclusive tutorials💍..."
        },
        {
          id: "7135efc4-f357-4de3-b15d-38f116e411dd",
          coverImg:"https://cdn2.suno.ai/535c4c12-bd6b-4b6c-8588-4466391eae6c_6aa9c106.jpeg",
          title: "Immersive Wandering",
          description:"The art of language"
        }
        
      ],
    },
    {
      title: "最好听英文",
      data: [
        {
          id: "8dcd4415-bf93-47c9-8e66-1d5c67599314",
          coverImg:"https://cdn2.suno.ai/5eff2480.jpeg",
          title: "Hot in March🔥",
          description:"relaxing songs "
        },
        {
          id: "00f8bc29-433a-4ae0-8214-508657965e63",
          coverImg:"https://cdn2.suno.ai/10b400ce.jpeg",
          title: "Style LO-FI English language",
          description:"Every word and every note in these songs ... "
        },
        
        
      ],
    },
  ];
}


async function getTopListDetail(topListItem) {
  const result = (await axios.get(`https://studio-api.suno.ai/api/playlist/${topListItem.id}/?page=0`, {
    headers
  })).data;

  return {
    isEnd: true,
    musicList: result.playlist_clips.map(it => {
      const clip = it.clip;

      return {
        id: clip.id,
        url: clip.audio_url,
        artwork: clip.image_large_url || clip.image_url,
        duration: clip.metadata?.duration,
        title: clip.title,
        artist: clip.display_name,
        userId: clip.user_id,
        rawLrc: clip.metadata?.prompt
      }
    })
  }
}

async function getLyric(musicItem) {
  return {
    rawLrc: musicItem.rawLrc
  }
}

module.exports = {
  platform: "SUNO",
  version: "0.1.9",
  imageUrl:"https://gitee.com/fish-job/MusicFreePlugins/raw/v0.2/images/suno.png",
  srcUrl:
    "https://gitee.com/fish-job/MusicFreePlugins/raw/v0.2/dist/suno/index.js",
  cacheControl: "no-cache",
  getTopLists,
  getTopListDetail,
  getLyric
};


getTopListDetail( {
  id: "1ac7823f-8faf-474f-b14c-e4f7c7bb373f",
  title: "最新榜",
}).then(e => console.log(e.musicList[0]))